﻿namespace SmlEngine
{
    /// <summary>
    /// Defines a gradient using rise and run values.
    /// </summary>
    public struct Gradient
    {
        /// <summary>
        /// Gets or sets the rise of the gradient.
        /// </summary>
        public float Rise { get; set; }

        /// <summary>
        /// Gets or sets the run of the gradient
        /// </summary>
        public float Run { get; set; }

        /// <summary>
        /// Gets or sets whether or not the gradient is inverted. 
        /// This will place the slope at the base of the tile.
        /// </summary>
        public bool Inverted { get; set; }

        /// <summary>
        /// Gets the slope of the gradient as a decimal.
        /// This is equivalent to Rise / Run.
        /// </summary>
        public float Slope { get { return Rise / Run; } }

        /// <summary>
        /// Constructs a new gradient from a rise/run pair.
        /// </summary>
        /// <param name="rise">The rise of the gradient</param>
        /// <param name="run">The run of the gradient</param>
        public Gradient(float rise, float run)
            : this(rise, run, false) { }

        /// <summary>
        /// Constructs a new gradient from a rise/run pair and optional inversion.
        /// </summary>
        /// <param name="rise">The rise of the gradient</param>
        /// <param name="run">The run of the gradient</param>
        /// <param name="inverted">Whether or not the Gradient is inverted.</param>
        public Gradient(float rise, float run, bool inverted)
            : this()
        {
            Rise = rise;
            Run = run;
            Inverted = inverted;
        }

        public static Gradient Flat { get { return new Gradient(0f, 1f); } }
    }
}
